<%@page import="com.ilibrary.constants.MyConstants"%>
<%@page import="com.ilibrary.web.vo.UserInfoVO"%>
<%@page import="com.ilibrary.web.vo.BookVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../_common.jsp" %>
<title>修改个人密码</title>
<link href="<%=request.getContextPath()%>/template_css/index/index.css" rel="stylesheet" type="text/css">
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/template_css/search/base.css">
<link type="text/css" rel="stylesheet" href="<%=request.getContextPath()%>/template_css/search/main.css">
</head>

<body>
	<%@include file="header.jsp" %>
	<div id="content" style="height: auto;overflow: hidden;">
		<div style="width: 100%;height: 25px;line-height: 30px;background-color: #FFFFCC;text-align: left;font-size: 14px;font-weight: bold;color: #A85300;">修改个人密码</div>
		<div style="width: 100%;height: 180px;">
		<form action="#" id="updatePwdForm" name="updatePwdForm" method="post">
			<table style="margin-top: 50px;">
				<tr>
					<td style="font-weight: bold;" align="right" width="100">旧&nbsp;密&nbsp;码:</td>
					<td><input id="oldPassword" type="password" style="height: 18px;margin-top: 0"></td>
					<td><font color="#999">6~10为数字或英文组合</font></td>
				</tr>
				<tr>
					<td style="font-weight: bold;" align="right" width="100">新&nbsp;密&nbsp;码:</td>
					<td><input id="newPassword" type="password" style="height: 18px;margin-top: 0"></td>
					<td><font color="#999">6~10为数字或英文组合</font></td>
				</tr>
				<tr>
					<td style="font-weight: bold;" align="right" width="100">确&nbsp;认&nbsp;密&nbsp;码:</td>
					<td><input id="conformNewPassword" type="password" style="height: 18px;margin-top: 0"></td>
				</tr>
				<tr>
					<td></td>
					<td align="right">
					<input type="button" onclick="document.getElementById('updatePwdForm').reset();" value="&nbsp;&nbsp;重&nbsp;&nbsp;置&nbsp;&nbsp;" style="cursor: pointer;">
					<input type="button" onclick="checkForm()" value="&nbsp;&nbsp;提&nbsp;&nbsp;交 &nbsp;&nbsp;" style="margin-left: 10px;cursor: pointer;"></td>
				</tr>
			</table>
		</form>
		</div>
		
		<div style="width: 100%;height: 30px;clear: both;"></div>
	</div>
	<%@include file="footer.jsp" %>
</body>

<script type="text/javascript">
	function checkForm() {
		var oldPassword = $('#oldPassword').val();
		var newPassword = $('#newPassword').val();
		var conformNewPassword = $('#conformNewPassword').val();
		if(oldPassword.length < 6 || oldPassword.length > 10) {
			alert("旧密码格式不符合要求!");
			$('#oldPassword').select();
			return;
		}
		if(newPassword.length < 6 || newPassword.length > 10) {
			alert("新密码格式不符合要求!");
			$('#newPassword').select();
			return;
		}
		if(newPassword != conformNewPassword) {
			alert("两次输入的密码不相同!");
			$('#newPassword').select();
			$('#conformNewPassword').val('');
			return;
		}
		$.ajax({
			url: '<%=request.getContextPath() %>/client/ajaxDoUpdateUserPassword.action',
			data: {
				'oldPassword':oldPassword,
				'newPassword':newPassword
			},
			type: 'post',
			dataType: 'json',
			async: 'false',
			success: function(msg) {
				if(!msg.success) {
					alert(msg.error);
					location.href = "";
				}else {
					alert("密码修改成功！");
					location.href = "<%=request.getContextPath() %>/client/index.action";
				}
			}
		});
	}
</script>

</html>
